package com.zbkc.main.base;

import com.zbkc.main.R;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

public class BaseTitleActivity extends BaseControlActivity implements
		View.OnClickListener {

	public static final int SUCCESS_MESSAGE = 1;
	private ImageView btnBack;
	private ImageView btnSure;
	private FrameLayout flContent;
	private TextView tvTitle;
	
	protected void onCreate(Bundle paramBundle) {
		super.onCreate(paramBundle);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.setContentView(R.layout.activity_base_title);
		bindView();
	}

	private void bindView() {
		tvTitle = ((TextView) findViewById(R.id.tv_title));
		btnBack = ((ImageView) findViewById(R.id.iv_back));
		btnBack.setOnClickListener(this);
		btnSure = ((ImageView) findViewById(R.id.iv_sure));
		btnSure.setOnClickListener(this);
		flContent = ((FrameLayout) findViewById(R.id.fl_content_container));
	}

	public void onClick(View paramView) {
		switch (paramView.getId()) {
		case R.id.iv_back:
			finish();
			break;
		}
	}

	@Override
	protected void onResume() {
		/**
		 * 设置为竖屏
		 */
		if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		}
		super.onResume();
	}

	public void setBtn1Visiable(boolean paramBoolean) {
		if (paramBoolean) {
			this.btnBack.setVisibility(0);
			return;
		}
		this.btnBack.setVisibility(8);
	}

	public void setBtn2Visiable(boolean paramBoolean) {
		if (paramBoolean) {
			this.btnSure.setVisibility(0);
			return;
		}
		this.btnSure.setVisibility(8);
	}

	public void setContentView(int paramInt) {
		View localView = getLayoutInflater().inflate(paramInt, null);
		this.flContent.removeAllViews();
		this.flContent.addView(localView, new ViewGroup.LayoutParams(-1, -1));
	}

	public void setContentView(View paramView) {
		this.flContent.removeAllViews();
		this.flContent.addView(paramView, new ViewGroup.LayoutParams(-1, -1));
	}

	public void setTitle(int paramInt) {
		this.tvTitle.setText(getResources().getString(paramInt));
	}

	public void setTitle(String paramString) {
		this.tvTitle.setText(paramString);
	}

}
